#include "dockwidgettitlebar.h"

#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>

using namespace gui;

DockWidgetTitleBar::DockWidgetTitleBar(const QString& title, QWidget* parent) : QFrame(parent)
{
    QHBoxLayout* layout = new QHBoxLayout();
    layout->setContentsMargins(QMargins(0, 0, 0, 0));
    layout->setSpacing(0);

    QPushButton* closeButton = new QPushButton();
    closeButton->setIcon(QIcon(":/gui/icons/close_icon.png"));
    closeButton->setIconSize(QSize(12, 12));

    QLabel* _title = new QLabel(title);

    layout->addWidget(_title, 2, Qt::AlignLeft | Qt::AlignVCenter);
    layout->addWidget(closeButton, 0, Qt::AlignCenter);

    setLayout(layout);

    connect(closeButton, SIGNAL(clicked()), parent, SLOT(close()));
}

DockWidgetTitleBar::~DockWidgetTitleBar()
{

}
